
package com.multimedia.room;

import java.util.ArrayList;
import java.util.List;

public class SwitchManager {

    private static SwitchManager sSwitchManager = new SwitchManager();
    //hands up switch
    private static List<ISwitch> mHandUpSwitchList = new ArrayList<ISwitch>();
    // dictation switch
    private static List<ISwitch> mDictationSwitchList = new ArrayList<ISwitch>();
    
    private static List<ISwitch> mTestSwitchList = new ArrayList<ISwitch>();
    
    // dictation switch
    private static List<ISwitch> mTranslateSwitchList = new ArrayList<ISwitch>();
    
    // dictation switch
    private static List<ISwitch> mMulticastSwitchList = new ArrayList<ISwitch>();

    // exam switch
    private static List<ISwitch> mExamSwitchList = new ArrayList<ISwitch>();

    // exam switch
    private static List<ISwitch> mAudioBroadcastList = new ArrayList<ISwitch>();

    // exam switch
    private static List<ISwitch> mUploadFileList = new ArrayList<ISwitch>();

    // exam switch
    private static List<ISwitch> mKillPlayerSwitchList = new ArrayList<ISwitch>();


    // exam switch
    private static List<ISwitch> mDiscussSwitchList = new ArrayList<ISwitch>();
    
    private SwitchManager() {

    }

    public static SwitchManager getInstance() {
        if (sSwitchManager == null) {
            return new SwitchManager();
        } else {
            return sSwitchManager;
        }
    }

    public void registerHandUpSwitch(ISwitch switch1) {
        mHandUpSwitchList.add(switch1);
    }

    public void unregisterHandUpSwitch(ISwitch switch1) {
        mHandUpSwitchList.remove(switch1);
    }
    public void registerDictationSwitch(ISwitch switch1) {
        mDictationSwitchList.add(switch1);
    }

    public void unregisterDictationSwitch(ISwitch switch1) {
        mDictationSwitchList.remove(switch1);
    }
    
    public void registerMulticastSwitch(ISwitch switch1) {
        mMulticastSwitchList.add(switch1);
    }

    public void unregisterMulticastSwitch(ISwitch switch1) {
        mMulticastSwitchList.remove(switch1);
    }
    
    public void registerTestSwitch(ISwitch switch1) {
        mTestSwitchList.add(switch1);
    }

    public void unregisterTestSwitch(ISwitch switch1) {
        mTestSwitchList.remove(switch1);
    }
    public void registerTranslateSwitch(ISwitch switch1) {
        mTranslateSwitchList.add(switch1);
    }

    public void unregisterTranslateSwitch(ISwitch switch1) {
        mTranslateSwitchList.remove(switch1);
    }
    
    public void registerExamSwitch(ISwitch switch1) {
        mExamSwitchList.add(switch1);
    }


    public void registerDiscussSwitch(ISwitch switch1) {
        mDiscussSwitchList.add(switch1);
    }

    public void unregisterDiscussSwitch(ISwitch switch1) {
        mDiscussSwitchList.remove(switch1);
    }
    public void registerUploadFileSwitch(ISwitch switch1) {
        mUploadFileList.add(switch1);
    }
    public void unRegisterUploadFileSwitch(ISwitch switch1) {
        mUploadFileList.remove(switch1);
    }

    public void unregisterKillPlayerSwitch(ISwitch switch1) {
    	mKillPlayerSwitchList.remove(switch1);
    }
    
    public void registerKillPlayerSwitch(ISwitch switch1) {
    	mKillPlayerSwitchList.add(switch1);
    }

    public void notifyKillPlayerSwitchStatus(boolean isOn,String params) {
        for (ISwitch is : mKillPlayerSwitchList) {
            if (isOn) {
                is.switchOn(params);
            } else {
                is.switchOff(params);
            }
        }
    }
    
    
    public void unregisterExamSwitch(ISwitch switch1) {
        mExamSwitchList.remove(switch1);
    }
    
    public List<ISwitch> getSwitchs() {
        return mHandUpSwitchList;
    }

    public void notifyHandUpSwitchStatus(boolean isOn,String params) {
        for (ISwitch is : mHandUpSwitchList) {
            if (isOn) {
                is.switchOn(params);
            } else {
                is.switchOff(params);
            }
        }
    }
    
    
    public void notifyExamSwitchStatus(boolean isOn,String params) {
        for (ISwitch is : mExamSwitchList) {
            if (isOn) {
                is.switchOn(params);
            } else {
                is.switchOff(params);
            }
        }
    }
    public void notifyDiscussSwitchStatus(boolean isOn,String params) {
        for (ISwitch is : mDiscussSwitchList) {
            if (isOn) {
                is.switchOn(params);
            } else {
                is.switchOff(params);
            }
        }
    }
    
    public void notifyDictationSwitchStatus(boolean isOn,String params) {
        for (ISwitch is : mDictationSwitchList) {
            if (isOn) {
                is.switchOn(params);
            } else {
                is.switchOff(params);
            }
        }
    }
    
    public void notifyTranslateSwitchStatus(boolean isOn,String params) {
        for (ISwitch is : mTranslateSwitchList) {
            if (isOn) {
                is.switchOn(params);
            } else {
                is.switchOff(params);
            }
        }
    }
    
    public void notifyTestSwitchStatus(boolean isOn ,String params) {
        for (ISwitch is : mTestSwitchList) {
            if (isOn) {
                is.switchOn(params);
            } else {
                is.switchOff(params);
            }
        }
    }
    
    
    public void notifyMulticastSwitchStatus(boolean isOn, String params) {
        for (ISwitch is : mMulticastSwitchList) {
            if (isOn) {
                is.switchOn(params);
            } else {
                is.switchOff(params);
            }
        }
    }

    public void registerAudioBtoadcaseSwitch(ISwitch switch1) {
        mAudioBroadcastList.add(switch1);
    }
    public void unRegisterAudioBtoadcaseSwitch(ISwitch switch1) {
        mAudioBroadcastList.add(switch1);
    }

    public void notifyAudioBroadSwitchStatus(boolean isOn, String params) {
        for (ISwitch is : mAudioBroadcastList) {
            if (isOn) {
                is.broadcastOn(params);
            } else {
                is.brocadOff(params);
            }
        }
    }

    public void notifyUploadFileAgain(boolean isOn, String params) {
        for (ISwitch is : mUploadFileList) {
            if (isOn) {
                is.broadcastOn(params);
            } else {
                is.brocadOff(params);
            }
        }
    }
}
